import UIKit

// 函数作为返回值

// 邮寄费用案例: 不同重量快递邮递费用计算方法不同,使用不同函数
func weigh1(weight: Int) -> Int {
  return 8
}

func weigh2(weight: Int) -> Int {
  return 8 + (weight - 2) * 2
}

func evaluePrice(weight: Int) -> Int {
	//可以嵌套函数
  func priceMethod(weight: Int) -> (Int) -> Int {
    if weight < 10 {
      return weigh1(weight:)
    } else {
      return weigh2(weight:)
    }
  }
  let method = priceMethod(weight: weight)
  return method(weight)
}

evaluePrice(weight: 10)
